<?php if ( ! defined('BASEPATH')) exit('No direct script access allowed');

class Login extends MY_Controller
{
	public function __construct()
	{
		parent::__construct();
		$this->load->model('User_model', 'user');
	}
    public function index()
    {
        $login_status  = $this->check_login_status();
        if (empty($login_status)){
        	$this->load->view('/');
        }else{
            redirect("/");
        }
    }
	/**
	 * 
	 */
	public function login()
	{
		$username = $this->input->post('username', TRUE);
		$password = $this->input->post('password', TRUE);
		$arr_res = $this->user->check_account($username, $password);
		if ($arr_res['status'] == 0){

             echo json_encode(array('code'=>0,'page'=>"index"));
		}else{
		    echo json_encode(array('code'=>-1,'message'=>$arr_res['message']));
		}
	}
    public function logout(){
        session_unset();
		session_destroy();
        $_SESSION['userInfo'] = null;
		redirect(BASEURL.'index/index');
    }
}
/* End of file login.php */
/* Location: ./application/controllers/luckydog/login.php */
